
const WS = "ws://192.168.202.52:8081/ws/";

class Socket {

    constructor(userId, device, callback) {
        this.webSockt = new WebSocket(WS + userId + "/" + device);

        this.webSockt.onopen = () => {
            console.log("123")
        }

        this.webSockt.onmessage = (res) => {
            let data = JSON.parse(res.data);
            this.message = data;
            typeof callback === 'function' && callback();
        }

        this.webSockt.onclose = () => {

        }
    }

}

export default Socket;
